﻿@Html.DevExpress().GridView(
            settings =>
            {
                settings.Name = "gvEditing";
                settings.KeyFieldName = "FPositionNo";
                settings.CallbackRouteValues = new { Controller = "Dept", Action = "PositionGrid" };
                settings.Width =System.Web.UI.WebControls.Unit.Percentage(96);


                //settings.CommandColumn.SetHeaderTemplateContent(column =>
                //{
                //    ViewContext.Writer.Write(
                //            "<span onclick='add()'>[新增]<span>"
                //        );
                //});

                //settings.SettingsEditing.AddNewRowRouteValues = new { Controller = "Dept", Action = "InlineEditingAddNewPartial" };
                //settings.SettingsEditing.UpdateRowRouteValues = new { Controller = "Dept", Action = "InlineEditingUpdatePartial" };
                //settings.SettingsEditing.DeleteRowRouteValues = new { Controller = "Dept", Action = "InlineEditingDeletePartial" };
                                
                
                //settings.CommandColumn.NewButton.Visible = true;
                //settings.CommandColumn.EditButton.Visible = true;
                //settings.CommandColumn.EditButton.Text = "修改";
                //settings.CommandColumn.DeleteButton.Visible = true;
                //settings.CommandColumn.DeleteButton.Text = "删除";
                //settings.SettingsBehavior.ConfirmDelete = true;




                settings.Columns.Add(column =>
                {
                    column.Caption = "#";
                    column.SetHeaderTemplateContent(c =>
                    {
                        Html.DevExpress().HyperLink(s => { s.Name = "linkAdd"; s.Properties.Text = "新增"; s.Properties.ClientSideEvents.Click = "positionAdd"; s.Style.Add(HtmlTextWriterStyle.Cursor, "pointer"); }).GetHtml();                       
                    });
                    column.SetDataItemTemplateContent(c =>
                    {

                        Html.DevExpress().HyperLink(s => { s.Name = "linkEdit" + c.VisibleIndex; s.Properties.Text = "修改"; s.Properties.ClientSideEvents.Click = "function(){positionEdit('" + DataBinder.Eval(c.DataItem, "FPositionNo") + "')}"; s.Style.Add(HtmlTextWriterStyle.Cursor, "pointer"); }).GetHtml();
                        ViewContext.Writer.Write("  ");
                        Html.DevExpress().HyperLink(s => { s.Name = "linkDel" + c.VisibleIndex; s.Properties.Text = "删除"; s.Properties.ClientSideEvents.Click = "function(){positionDel('" + DataBinder.Eval(c.DataItem, "FPositionNo") + "')}"; s.Style.Add(HtmlTextWriterStyle.Cursor, "pointer"); }).GetHtml();
                        //Html.DevExpress().HyperLink(d => { d.Name = "link" + c.VisibleIndex; d.Properties.Text = "增加"; d.Properties.ClientSideEvents.Click = "function(s,e){gvEditing.AddNewRow()}"; }).Render();

                        //ViewContext.Writer.Write(
                        //    "<span onclick='edit(\"" + DataBinder.Eval(c.DataItem, "FPositionNo") + "\"," + c.VisibleIndex + ")'>[修改]<span>"

                        //    //Html.ActionLink("Edit", "EditingEdit", new { ProductID = DataBinder.Eval(c.DataItem, "ProductID") }) + "&nbsp;" +
                        //    //Html.ActionLink("Delete", "EditingDelete", new { ProductID = DataBinder.Eval(c.DataItem, "ProductID") },
                        //    //    new { onclick = "return confirm('Do you really want to delete this record?')" })
                        //);
                    });
                    column.Settings.AllowDragDrop = DefaultBoolean.False;
                    column.Settings.AllowSort = DefaultBoolean.False;
                    column.Width = 70;
                });



                settings.Columns.Add("FPositionNo", "岗位编号");

                //settings.Columns.Add(c => {
                //    c.Caption = "岗位编号";
                //    c.FieldName = "FPositionNo";
                //    c.HeaderStyle.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Center;
                //});
                
                settings.Columns.Add("FPositionName", "岗位名称");
                settings.Columns.Add("FPositionPropName", "岗位性质");
                settings.Columns.Add("FSeq","显示顺序");


                settings.SettingsBehavior.AllowSort = false;
                settings.SettingsBehavior.AllowDragDrop = false;
                settings.SettingsBehavior.AllowSelectByRowClick = false;
                settings.SettingsLoadingPanel.Text = "数据读取中...";
                settings.SettingsBehavior.AllowClientEventsOnLoad = false;
                settings.SettingsBehavior.AllowFocusedRow = true;


                settings.ClientSideEvents.BeginCallback = "function(s,e){OnBeginCallback(s,e)}";
                settings.CommandColumn.Visible = false;
                //settings.CommandColumn.ShowSelectCheckbox = true;
                
                //settings.ClientSideEvents.RowDblClick = "SelectionChanged";

                                                               
                
            }).Bind(Model).GetHtml()

